package com.example.fw;

import static org.junit.Assert.fail;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class WebDriverHelper {

	private static WebDriver driver;
	public static String baseUrl;
	private StringBuffer verificationErrors = new StringBuffer();
	private ApplicationManager manager;

	public WebDriverHelper(ApplicationManager manager) {
		// WebDriverHelper's constructor
		this.manager = manager;
		driver = new FirefoxDriver();
		baseUrl = "http://localhost/";
		driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
		driver.get(baseUrl + "addressbookv4.1.4/");

	}

	public void stop() {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}

	public WebDriver getDriver() {
		return driver;
	}

}
